/**
 * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.gravitee.am.common.webauthn;

/**
 * WebAuthn Relying Parties may use AttestationConveyancePreference to specify their preference regarding attestation conveyance during credential generation.
 *
 * none
 * This value indicates that the Relying Party is not interested in authenticator attestation. For example, in order to potentially avoid having to obtain user consent to relay identifying information to the Relying Party, or to save a roundtrip to an Attestation CA.
 * This is the default value.
 *
 * indirect
 * This value indicates that the Relying Party prefers an attestation conveyance yielding verifiable attestation statements, but allows the client to decide how to obtain such attestation statements. The client MAY replace the authenticator-generated attestation statements with attestation statements generated by an Anonymization CA, in order to protect the user’s privacy, or to assist Relying Parties with attestation verification in a heterogeneous ecosystem.
 * Note: There is no guarantee that the Relying Party will obtain a verifiable attestation statement in this case. For example, in the case that the authenticator employs self attestation.
 *
 * direct
 * This value indicates that the Relying Party wants to receive the attestation statement as generated by the authenticator.
 *
 * See <a href="https://www.w3.org/TR/webauthn/#attestation-convey">Attestation Conveyance Preference Enumeration (enum AttestationConveyancePreference)</a>
 *
 * @author Titouan COMPIEGNE (titouan.compiegne at graviteesource.com)
 * @author GraviteeSource Team
 */
public enum AttestationConveyancePreference {

    NONE("none"),
    INDIRECT("indirect"),
    DIRECT("direct");

    private final String value;

    AttestationConveyancePreference(String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    public static AttestationConveyancePreference fromString(String value) {
        for (AttestationConveyancePreference a : AttestationConveyancePreference.values()) {
            if (a.value.equalsIgnoreCase(value)) {
                return a;
            }
        }
        throw new IllegalArgumentException("No attestation with value [" + value + "] found");
    }
}
